package com.glls.customer.service.impl;

import com.glls.common.R;
import com.glls.common.entity.Goods;
import com.glls.customer.feign.SearchFeignClient;
import com.glls.customer.service.CustomerService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * TODO
 *
 * @author junyang
 * @version 1.0.0
 * @date 2025/2/20 9:33
 */
@Service
public class CustomerServiceImpl implements CustomerService {



    @Resource
    private SearchFeignClient searchFeignClient;

    @Override
    public Goods findGoodsByIdWithFeign(Integer id) {
        //通过feign 远程调用，就好像调用本地方法一样
        Goods goods = searchFeignClient.search(id);
        return goods;
    }

    @Override
    public R findGoodsListWithFeign() {

        R r = searchFeignClient.searchGoodsList(new Goods(1, "电脑", 66.66));

        return r;
    }
    @Override
    public Map saveGoods(@RequestBody Goods goods) {
        return searchFeignClient.save(goods);
    }

    @Override
    public Map updateGoods(@RequestBody Goods goods) {
        return searchFeignClient.update(goods);
    }

    @Override
    public Map deleteGoods(@RequestParam("id") Integer id) {
        return searchFeignClient.deleteById(id);
    }

    @Override
    public Goods getjiFenById(@PathVariable("id") Long id) {
        return searchFeignClient.findJifenById(id);
    }
    public Goods search(Integer id,String name){
        return searchFeignClient.search(id);
    }

}
